package shy.mapper;
import org.apache.ibatis.annotations.*;
import shy.bean.Adoptive;

import java.util.List;


@Mapper
public interface AdoptiveMapper {
    //    获取所有领养者信息
    @Select("select * from wams_adoptive where state=0")
    List<Adoptive> findAllAdoptive();

    //删除指定领养者：逻辑删除
    @Update("update wams_adoptive set state=1 where id=#{id}")
    int deleteById(int id);

    @Select("select * from wams_adoptive " +
            "where state=0 and adoCode like #{adoCode} and adoName like #{adoName}")
    List<Adoptive> findAdoptiveByCodeAndName(@Param("adoCode") String adoCode, @Param("adoName") String adoName);

    @Insert("insert into wams_adoptive(id,adoCode,adoName,phone,address,gender,pet,state)" +
            " values(null,#{adoCode},#{adoName},#{phone},#{address},#{gender},#{pet},0)")
    int saveAdoptive(Adoptive adoptive);

    @Update("update wams_adoptive set adoName=#{adoName},adoCode=#{adoCode},gender=#{gender},address=#{address},phone=#{phone},pet=#{pet} where id=#{id}")
    int updateAdoptive(Adoptive adoptive);
}



